<template>
	<view>
		<view>
			<view class="info">
				<!-- 表格数据行 -->
				<view class="user" >
					<view class="user_item ">用户ID:{{user.userId}}</view>
					<view class="user_item ">用户昵称:{{user.username}}</view>
					<view class="user_item ">邮箱:{{user.email}}</view>
					<view class="user_item ">权限:{{user.role}}</view>
					<view class="user_item ">注册时间:{{user.createTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:''
			}
		},
		onShow() {
				this.initData()
			},
			methods: {
				hanleUserInfo(){
					uni.navigateTo({
						url:"../admin_user_info/admin_user_info"
					})
				},
				initData(){
					uni.request({
						url:'/api/user/getUserInfo',
						method:'get',
						header:{
							'Authorization':this.$store.getters.token
						},
						success: (res) => {
							if(res.data.code===200){
								this.user = res.data.data
								if( res.data.data.role === 1){
									this.user.role = '教师'
								}else if(res.data.data.role === 3){
									this.user.role = '教务老师'
								}else{
									this.user.role = '管理员'
								}
							}else{
								uni.showToast({
									icon:'error',
									position:'bottom',
									title:'查询失败'
								})
							}
						},})
					}
				}
			}
</script>

<style>
.user{
	font-size: 30rpx;
	border-radius: 10rpx;
	margin: 10rpx;
	display: flex;
	flex-direction: column;
}
.user_item{
	margin: 20px;
	border-bottom: 2px solid #dddddd;
}
</style>
